<?php
class CMRPageViewActionHistory extends CMRPage
{
	protected function getContentsDiv()
	{
		$html = "<div id=\"content\">\n";
		$html .= "<h1>Action History</h1>";

		$sectionsPanel = new SectionsPanel('');
		$html .= $sectionsPanel->getHTML();
		
		$hidden = new Hidden();
		$hidden->setName("ActionNext20Start");
		$hidden->setValue('0');
		$html .= $hidden->getHTML();

		$html .= "<div id=\"actionlist\">\n";
		$html .= "<table>\n";

		$sql = "SELECT * from Actions ORDER BY ActionDate DESC LIMIT 20";
		$this->Database->ExecuteSQL($sql);
		while($row=$this->Database->getRow())
		{
			$resource = new Resource($this->Database,$row['ResourceID']);
			
			// get action name
			$sql1 = "SELECT LongName from ActionTypes where ActionTypeID = ".$row['ActionTypeID'];
//			echo $sql1."<br>\n";
			$database1 = $this->Database->recopy();
			$database1->ExecuteSQL($sql1);
			$row1 = $database1->getRow();
//			print_r($row1);
			
			// get user
			$sql1 = "SELECT LongName from Users where UserID = ".$row['ActionUserID'];
			$database1->ExecuteSQL($sql1);
			$row2 = $database1->getRow();
//			print_r($row2);
			
			$date = new DateTime($row['ActionDate']);
			
			$html .= "<tr><td style=\"width:120px;\">".
			$date->format("D j M Y H:i")."</td><td style=\"width:80px;\">".
			$row2['LongName']."</td><td style=\"width:50px;\">".
			$row1['LongName']."</td><td style=\"width:250px;\">".
			"(".$resource->getResourceID().") ".
			$resource->getResourceTitle()."</td><td>".
			$row['ActionComment']."</td></tr>\n";
		}
	
		$html .= "</table>\n";
		$html .= "</div>\n"; // end of actionlist

		$button = new JavascriptButton();
		$button->setName("ActionNext20Button");
		$button->setJavaScript("ActionNext20();");
		$button->setValue("Next 20");
		$html .= "<p style=\"text-align:center;\">".$button->getHTML()."<p>\n";
		
	
		$html .= "</div>\n"; // end of content
		return $html;
	}
}
				

?>